import Mock from 'mockjs';

const data = Mock.mock({
    'list|10': [
        {
            id: 'hotel-' + '@guid',
            'name|1': [
                '锦江之星风尚酒店(北京三里屯店)',
                '北京万达文华酒店',
                '北京广渠门漫心酒店',
                '全季酒店(北京天坛店)',
                '北京望京希尔顿欢朋酒店'
            ],
            'address|1': [
                '北京市东城区东直门外南二里庄29号1幢',
                '北京市朝阳区建国路93号万达广场C座',
                '北京市海淀区西二旗北路10号院1号楼',
                '北京市东城区东四块玉南街11号'
            ],
            'price': '@integer(300, 999)',
            'imgUrl|1': [
                'https://cdn7.axureshop.com/demo2024/2251242/images/%E9%85%92%E5%BA%97%E9%A2%84%E8%AE%A2/u1344.svg',
                'https://cdn7.axureshop.com/demo2024/2251242/images/%E9%85%92%E5%BA%97%E9%A2%84%E8%AE%A2/u1344-0.svg',
                'https://cdn7.axureshop.com/demo2024/2251242/images/%E9%85%92%E5%BA%97%E9%A2%84%E8%AE%A2/u1344-1.svg',
                'https://cdn7.axureshop.com/demo2024/2251242/images/%E9%85%92%E5%BA%97%E9%A2%84%E8%AE%A2/u1344-2.svg',
                'https://cdn7.axureshop.com/demo2024/2251242/images/%E9%85%92%E5%BA%97%E9%A2%84%E8%AE%A2/u1344-3.svg',
            ]
        }
    ]
});



Mock.mock('/api/getHotel', 'post', () => {
    return {
        code: 200,
        message: '获取数据成功',
        data: data.list
    }
});


Mock.mock('/api/searchHotel', 'post', (config) => {
    const { name } = JSON.parse(config.body);
    //@ts-ignore
    const result = data.list.filter(item => {
        return item.name.includes(name)
    });
    return {
        code: 200,
        message: '搜索成功',
        data: result
    }
})